package com.example.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class Contact extends Activity implements View.OnClickListener {
    String name;
    String number;

    TextView nameText;
    TextView numberText;

    @Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contacts);

        Bundle bundle = getIntent().getExtras();
        name = bundle.getString("name");
        number = bundle.getString("number");
        bindViews();
    }

    public void bindViews(){
        nameText = findViewById(R.id.name2);
        numberText = findViewById(R.id.num2);
        nameText.setText(name);
        numberText.setText(number);

        numberText.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Uri uri=Uri.parse("tel:"+number);
        Intent intent=new Intent(Intent.ACTION_DIAL,uri);
        startActivity(intent);

    }
}
